import actionType from  "../action"
//state表示数据
//action表示如何修改数据
let  userReducer = (state={list:[]},action:any)=>{
    switch(action.type){
        case  actionType.INITUSERLIST:
            return {list:action.payload}
         case  actionType.ADDUSERITEM:
             return  {list:[...state.list,action.payload]}  
         case  actionType.DELETEUSER:
             return   {list:state.list.filter((item:any)=>item._id!==action.payload)} 

    }
    return  state;
}
export  default  userReducer;